package com.workingpub.commons.domain;

import java.util.Date;

import javax.persistence.Column;
import javax.persistence.DiscriminatorColumn;
import javax.persistence.DiscriminatorType;
import javax.persistence.Entity;
import javax.persistence.Inheritance;
import javax.persistence.InheritanceType;
import javax.persistence.Table;

/**
 * 字典表基类，基本标准数据表T_SD_Dictionary单表继承定义，主要用于数据关联读取 <br>
 * 子类需指定标准定义Id
 * 
 * @author taoping
 *
 */
@Entity
@Table(name = "T_SD_Dictionary")
@Inheritance(strategy = InheritanceType.SINGLE_TABLE)
@DiscriminatorColumn(name = "define_id", discriminatorType = DiscriminatorType.STRING)
public abstract class AbstractDictionary extends AssignedDomainGeneral implements UnDeletable {

	private static final long serialVersionUID = 8474814896744443051L;

	@Column(name = "value")
	private String value;

	@Column(name = "priority")
	private Integer priority;

	@Column(name = "description")
	protected String description;

	@Column(name = "is_deleted")
	protected Boolean isDeleted = Boolean.FALSE;

	@Column(name = "create_date")
	protected Date createDate;

	@Override
	public boolean deleted() {
		return null == this.isDeleted ? false : this.isDeleted.booleanValue();
	}

	@Override
	public void markedAsAvailable() {
		this.isDeleted = Boolean.FALSE;
	}

	@Override
	public void markedAsDeleted() {
		this.isDeleted = Boolean.TRUE;
	}

	@Override
	public String toString() {
		return new StringBuilder("id : " + id).append("\tname : " + name).append("\tisDeleted : " + isDeleted)
				.append("\tcreateDate : " + createDate).toString();
	}

	public Integer getPriority() {
		return priority;
	}

	public void setPriority(Integer priority) {
		this.priority = priority;
	}

	public String getValue() {
		return value;
	}

	public void setValue(String value) {
		this.value = value;
	}

	public String getDescription() {
		return description;
	}

	public void setDescription(String description) {
		this.description = description;
	}

	public Boolean getIsDeleted() {
		return isDeleted;
	}

	public void setIsDeleted(Boolean isDeleted) {
		this.isDeleted = isDeleted;
	}

	public Date getCreateDate() {
		return createDate;
	}

	public void setCreateDate(Date createDate) {
		this.createDate = createDate;
	}

}
